package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.LoginAuth;
import com.micro.modual.extension.LoginAuthExtension;
import com.micro.modual.mapper.LoginAuthMapper;
import com.micro.modual.model.bo.loginauth.LoginAuthBO;
import com.micro.modual.service.LoginAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>用户登录授权表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("loginAuthService")
public class LoginAuthServiceImpl extends AbstractBasicsServiceImpl<LoginAuth,Long> implements LoginAuthService {

    @Autowired
    private LoginAuthMapper loginAuthMapper;

    /**
     * <h2>新增用户登录授权表详情</h2>
     * @param loginAuthBO {@link LoginAuthBO} 用户登录授权表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addLoginAuth(LoginAuthBO loginAuthBO) {
        LoginAuth loginAuth = LoginAuthExtension.converAddLoginAuth(loginAuthBO);
        loginAuthMapper.insertSelective(loginAuth);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改用户登录授权表详情</h2>
     * @param loginAuthBO  {@link LoginAuthBO} 用户登录授权表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editLoginAuth(LoginAuthBO loginAuthBO) {
        LoginAuth loginAuth = LoginAuthExtension.converEditLoginAuth(loginAuthBO);
        loginAuthMapper.updateByPrimaryKeySelective(loginAuth);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除用户登录授权表信息</h2>
     * @param id  用户登录授权表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteLoginAuth(Long id) {
        loginAuthMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
